package com.ymatou.iapi.productprice.testcase;

import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.productprice.parameter.PriceConfig;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productprice.parameter.ProductPriceBean;
import com.ymatou.iapi.productprice.service.GetCatalogPriceListByDeliveryTradeIsolationCall;
import com.ymatou.iapi.productprice.service.GetPriceByCatalogIdsTradeIsolationCall;
import com.ymatou.iapi.productprice.service.GetPriceByProdIdCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.YMTDateUtil;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;

public class Ts_GetPriceByCatalogIdsTradeIsolation {
	private static int newBuyerId = ProductPriceCallService.getNewCustomer();
	private static int oldBuyerId = ProductPriceCallService.getOldCustomer();
	private static GetPriceByCatalogIdsTradeIsolationCall getPriceByCatalogIdsTradeIsolationCall = new GetPriceByCatalogIdsTradeIsolationCall();
	private static ProductTimeStampWapper productTimeStampWapper = new ProductTimeStampWapper();
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();

	private static GetPriceByProdIdCall getPriceByProdIdCall = new GetPriceByProdIdCall();

	private static GetCatalogPriceListByDeliveryTradeIsolationCall getCatalogPriceListByDeliveryTradeIsolationCall = new GetCatalogPriceListByDeliveryTradeIsolationCall();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("交易隔离查询接口, 根据商品catalogs list查询商品价格");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getPriceByCatalogIdsTradeIsolationCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_001() {
		Logger.start(true, "非交易隔离,普通新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为普通商品价格逻辑
			// vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			// no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBean, inaid);

				// 新客修改后价格检查 读缓存活动价格
				ProductPriceBean newProductPriceUpdate = PriceConfig.isCacheActivityProduct
						? ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean, true, false)
						: ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true,
								false);

				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查 价格读库
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);

				// 修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBeanUpdate, inaid);

				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				if (PriceConfig.isCacheActivityProduct) {
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
				} else {
					ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
							.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate2, true, false);
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);
				}

				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 修改时间戳，应该查询mongo库中数据，结果发生变化
				// productTimeStampWapper.update(productId,
				// MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate2, true, false);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_002() {
		Logger.start(true, "非交易隔离,非新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBean, inaid);

				// 新客修改后价格检查
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);

				// 老客修改后价格检查
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);

				if (PriceConfig.isCacheActivityProduct) {
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				} else {
					ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
							.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true, false);
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

					ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
							.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, false, false);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
				}

				// 修改时间戳，应该查询mongo库中数据，结果发生变化
				// productTimeStampWapper.update(productId,
				// MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true, false);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, false, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);

			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_003() {
		Logger.start(true, "交易隔离,新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为普通商品价格
			// vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			// no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBean, inaid);

				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = PriceConfig.isCacheActivityProduct
						? ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean, true, false)
						: ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true,
								false);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);

				// 修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBeanUpdate, inaid);

				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 修改时间戳，应该查询mongo库中数据，结果发生变化
				// productTimeStampWapper.update(productId,
				// MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate2, true, false);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_004() {
		Logger.start(true, "交易隔离,非新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBean, inaid);

				// 新客修改后价格检查
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);

				// 老客修改后价格检查
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);

				if (PriceConfig.isCacheActivityProduct) {
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				} else {
					ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
							.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true, false);
					ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

					ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
							.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, false, false);
					ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);
				}

				// 修改时间戳，应该查询mongo库中数据，结果发生变化
				// productTimeStampWapper.update(productId,
				// MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, true, false);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate, false, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_005() {
		Logger.start(true, "普通商品");
		try {

			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId, 0);

			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, true);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为普通商品价格
			// vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			// no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库价格，由于缓存里面没有该商品记录，所以结果应该查数据库
				// int inaid =
				// Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBean);

				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate, true);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 通过商品查价格，缓存该商品规格数据
				getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);

				// 修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate2 = ProductPriceCallService
						.updatePriceInMgo(productAllPriceBeanUpdate);

				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);

				// 修改时间戳，应该查询mongo库中数据，结果发生变化
				// productTimeStampWapper.update(productId,
				// MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2, true);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate2);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate2 = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate2, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate2);

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_006() {
		Logger.start(true, "活动结束，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库活动商品结束时间，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				// activityProductsWapper.update(inaid,
				// MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
				AdminCallService.closeProductInActivity(String.valueOf(inaid));

				// 新客修改后价格检查
				YMTDateUtil.waitTime(2);
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, true);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_007() {
		Logger.start(true, "活动库存为0，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();
			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			// 1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

			// 2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

			if (PriceConfig.isCacheCheck) {
				Logger.debug("缓存检查");
				// ===========================================================================================================
				// 修改mongo数据库活动库存，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				// 新客修改后价格检查
				YMTDateUtil.waitTime(2);
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, true);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPriceUpdate);
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Ignore
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_008() {
		Logger.start(true, "删除时间戳表后，查询");
		try {
			if (PriceConfig.isCacheCheck) {
				ProductAllPriceBean productAllPriceBean = ProductPriceCallService
						.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
				String productId = productAllPriceBean.getProductId();
				List<String> catalogs = new ArrayList<>();
				productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

				// 删除时间戳表记录
				productTimeStampWapper.delete(productId);

				// 1 码头新客户 查询结果为活动价格
				ProductPriceBean newProductPrice = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
				JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPrice);

				// 2码头老客户查询结果为活动价格
				ProductPriceBean oldProductPrice = ProductPriceCallService
						.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
				JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

				// 修改 Mongo 数据库活动库存
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);

				YMTDateUtil.waitTime(5);
				// 新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, true);
				ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret, newProductPriceUpdate);

				// 老客修改后价格检查
				// vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				oldProductPrice = ProductPriceCallService
						.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean, false);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);

				// no vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId,
						false);
				oldProductPrice = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
				ProductPriceCallService.checkPriceListByCatalogs(ret2, oldProductPrice);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_009() {
		Logger.start(true, "非交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndNoIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();

			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			Map<String, Integer> catalogsMap = new HashMap<>();
			catalogs.forEach(ele -> catalogsMap.put(ele, 1));

			int prodInActivityId = Integer
					.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			// 新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			// 新客 会员价
			ProductPriceBean priceIncludeActivity_NewCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			// 老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			// 老客 会员价
			ProductPriceBean priceIncludeActivity_OleCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			// 原价
			ProductPriceBean priceIncludeActivity_OleOrig = ProductPriceCallService
					.getProductOrigPriceBeanByUserLevel(productAllPriceBean, false);

			// 会员政策1， 会员等级3以上才能享受活动价

			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			// 0级会员 新客 普通价
			JSONObject ret1 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret1, priceIgnoreActivity_NewCust);

			JSONObject ret1_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_1, priceIgnoreActivity_NewCust);

			JSONObject ret1_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_2, priceIgnoreActivity_NewCust);

			// 6级会员 老客 会员活动价
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, priceIncludeActivity_OleCust);

			JSONObject ret2_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_1, priceIncludeActivity_OleCust);

			JSONObject ret2_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_2, priceIncludeActivity_OleCust);

			// 会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2,
					"2015-01-02 00:00:00,2016-03-23 23:59:59");

			// 新客 注册时间2015-05-26 14:20:04 会员活动价
			JSONObject ret3 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret3, priceIncludeActivity_NewCust);

			JSONObject ret3_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_1, priceIncludeActivity_NewCust);

			JSONObject ret3_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_2, priceIncludeActivity_NewCust);

			// 老客 注册时间2016-04-22 10:19:05 普通价格
			JSONObject ret4 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret4, priceIgnoreActivity_OleCust);

			JSONObject ret4_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_1, priceIgnoreActivity_OleCust);

			JSONObject ret4_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_2, priceIgnoreActivity_OleCust);

			// 会员政策3， 会员标签满足才能享受活动价 标签值 3
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 3, "3");

			// 新客 标签3 会员活动价
			JSONObject ret5 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret5, priceIncludeActivity_NewCust);

			JSONObject ret5_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_1, priceIncludeActivity_NewCust);

			JSONObject ret5_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_2, priceIncludeActivity_NewCust);

			// 老客 没标签 普通价格
			// vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			JSONObject ret6 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret6, priceIgnoreActivity_OleCust);

			// not vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ret6 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret6, priceIncludeActivity_OleOrig);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);

			JSONObject ret6_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_1, priceIgnoreActivity_OleCust);

			JSONObject ret6_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_2, priceIgnoreActivity_OleCust);

			// 会员政策3， 会员标签满足才能享受活动价 标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 3, "4");

			// 新客 标签3 普通价
			JSONObject ret7 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret7, priceIgnoreActivity_NewCust);

			JSONObject ret7_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_1, priceIgnoreActivity_NewCust);

			JSONObject ret7_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_2, priceIgnoreActivity_NewCust);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_010() {
		Logger.start(true, "交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService
					.getProdPriceWithActivity_NoNewBuyerAndIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			List<String> catalogs = new ArrayList<>();

			productAllPriceBean.getCatalogAllPriceBeans().forEach(ele -> catalogs.add(ele.getCatalogId()));

			Map<String, Integer> catalogsMap = new HashMap<>();
			catalogs.forEach(ele -> catalogsMap.put(ele, 1));

			int prodInActivityId = Integer
					.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			// 新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			// 新客 会员价
			ProductPriceBean priceIncludeActivity_NewCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, true, false);
			// 老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);
			// 老客 会员价
			ProductPriceBean priceIncludeActivity_OleCust = ProductPriceCallService
					.getProductPriceBeanByUserLevel(productAllPriceBean, false, false);

			// 会员政策1， 会员等级3以上才能享受活动价

			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			// 0级会员 新客 普通价
			JSONObject ret1 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret1, priceIgnoreActivity_NewCust);

			JSONObject ret1_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_1, priceIgnoreActivity_NewCust);

			JSONObject ret1_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret1_2, priceIgnoreActivity_NewCust);

			// 6级会员 老客 会员活动价
			JSONObject ret2 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret2, priceIncludeActivity_OleCust);

			JSONObject ret2_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_1, priceIncludeActivity_OleCust);

			JSONObject ret2_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret2_2, priceIncludeActivity_OleCust);

			// 会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2,
					"2015-01-02 00:00:00,2016-03-23 23:59:59");

			// 新客 注册时间2015-05-26 14:20:04 会员活动价
			JSONObject ret3 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret3, priceIncludeActivity_NewCust);

			JSONObject ret3_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_1, priceIncludeActivity_NewCust);

			JSONObject ret3_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret3_2, priceIncludeActivity_NewCust);

			// 老客 注册时间2016-04-22 10:19:05 普通价格
			JSONObject ret4 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret4, priceIgnoreActivity_OleCust);

			JSONObject ret4_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_1, priceIgnoreActivity_OleCust);

			JSONObject ret4_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret4_2, priceIgnoreActivity_OleCust);

			// 会员政策3， 会员标签满足才能享受活动价 标签值 3
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 3, "3");

			// 新客 标签3 会员活动价
			JSONObject ret5 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret5, priceIncludeActivity_NewCust);

			JSONObject ret5_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_1, priceIncludeActivity_NewCust);

			JSONObject ret5_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret5_2, priceIncludeActivity_NewCust);

			// 老客 没标签 普通价格
			JSONObject ret6 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(oldBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret6, priceIgnoreActivity_OleCust);

			JSONObject ret6_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_1, priceIgnoreActivity_OleCust);

			JSONObject ret6_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(oldBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret6_2, priceIgnoreActivity_OleCust);

			// 会员政策3， 会员标签满足才能享受活动价 标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 3, "4");

			// 新客 标签3 普通价
			JSONObject ret7 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId, catalogs);
			ProductPriceCallService.checkPriceListByCatalogs(ret7, priceIgnoreActivity_NewCust);

			JSONObject ret7_1 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_1, priceIgnoreActivity_NewCust);

			JSONObject ret7_2 = getCatalogPriceListByDeliveryTradeIsolationCall.callAndGetReturnData2(newBuyerId,
					catalogsMap);
			ProductPriceCallService.checkPriceListByCatalogs(ret7_2, priceIgnoreActivity_NewCust);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	/////////////////////忽略case ///////////////////
	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetPriceByCatalogIdsTradeIsolation_011() {
		Logger.start(true, "查询限时抢八折后价格");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, false);
			double price = 123.6;
			addAgentProductBean.getCatalogList().forEach(a -> {
				a.getAgentPriceList().forEach(b -> {
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 创建限时抢购活动
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,
					productId);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});
			List<String> catalogs=new ArrayList<String>();
			
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId,
					productId, catalogList);
			initProductaddactivity.getProductList().forEach(a -> {
				a.getCatalogList().forEach(b -> {
					catalogs.add(b.getCatalogId());
					b.setDiscount(new BigDecimal("8"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);

			JSONObject callAndGetReturnData = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId,catalogs);
			JSONObject asJsonObject1 = callAndGetReturnData.getJSONObject("Data")
					.getJSONArray("CatalogPriceList").getJSONObject(1).getJSONObject("CatalogInfo");
			JSONObject asJsonObject2 = callAndGetReturnData.getJSONObject("Data")
					.getJSONArray("CatalogPriceList").getJSONObject(1).getJSONObject("CatalogInfo");
			Logger.verifyEquals(price * 0.8, asJsonObject1.getDouble("Price"), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject2.getDouble("Price"), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject1.getDouble("ActivityPrice"), "验证是否为八折价格");
			Logger.verifyEquals(price * 0.8, asJsonObject2.getDouble("ActivityPrice"), "验证是否为八折价格");
			Logger.verifyEquals(price, asJsonObject1.getDouble("QuotePrice"), "验证是否为原价");
			Logger.verifyEquals(price, asJsonObject2.getDouble("QuotePrice"), "验证是否为原价");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByCatalogIdsTradeIsolation_999() {
		Logger.start(true, "非法数据测试");
		try {
			// 不存在 商品id
			JSONObject ret = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(newBuyerId,
					Arrays.asList("111212312"));
			Logger.verifyEquals(201, ret.getInt("Code"), "返回报文 Code字段检查");
			ProductPriceCallService.checkInvalidResponse(ret);

			// buyerid<0
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			JSONObject ret1 = getPriceByCatalogIdsTradeIsolationCall.callAndGetReturnData(-1, Arrays.asList(productId));
			Logger.verifyEquals(201, ret.getInt("Code"), "返回报文 Code字段检查");
			ProductPriceCallService.checkInvalidResponse(ret1);

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

}
